from django.db import models

# Create your models here.

class CarStyle(models.Model):
    '''车辆的类型：两厢轿车，三厢轿车，跑车，suv，mpv，皮卡，面包车'''
    name = models.CharField(max_length=8,verbose_name='车的种类')
    image = models.ImageField(upload_to='type',verbose_name='车型代表性图片')

    def __str__(self):
        return  self.name

    class Meta:
        verbose_name = '车辆类型'
        verbose_name_plural = verbose_name
class Brande(models.Model):
    name = models.CharField(max_length=10,verbose_name='车的品牌')

    def __str__(self):
        return  self.name

    class Meta:
        verbose_name = '车辆品牌'
        verbose_name_plural = verbose_name
class CarDetail(models.Model):
    status_choice=(
        (1,'上线'),
        (0,'下线')
    )

    user = models.ForeignKey('user.UserInfo',verbose_name='所属人')
    style = models.ForeignKey('CarStyle', verbose_name='所属的类型')
    brande = models.ForeignKey('Brande', verbose_name='所属的品牌')
    car_model = models.CharField(max_length=5,verbose_name='车型')
    # image = models.ImageField(upload_to= '/detail_img',verbose_name='车辆细节图')
    color = models.CharField(max_length=5,verbose_name='颜色')
    age = models.CharField(max_length=10,verbose_name='车龄')
    Transmission_case = models.CharField(max_length=10,verbose_name='变速箱')
    Mileage = models.DecimalField(max_digits=10, decimal_places=2,verbose_name='里程量')
    displacement = models.CharField(max_length=10, verbose_name='排量')
    emission_standard = models.CharField(max_length=10,verbose_name='排放标准')
    fuel_type = models.CharField(max_length=10,verbose_name='燃油类型')
    license_plate_location = models.CharField(max_length=20,verbose_name='车牌所在地')
    drive = models.CharField(max_length=10,verbose_name='驱动类型')
    country = models.CharField(max_length=10,verbose_name='国别')
    car_price = models.DecimalField(max_digits=10,decimal_places=5,verbose_name='二手车价格')
    status = models.IntegerField(default=1,choices=status_choice,verbose_name='状态')

    def __str__(self):
        return self.car_model
    class Meta:
        verbose_name = '车辆属性'
        verbose_name_plural = verbose_name



class Image_detail(models.Model):
    path = models.ImageField(upload_to='/detail_img',verbose_name='车辆细节图')
    index = models.IntegerField(verbose_name='顺序')
    car_detail = models.ForeignKey('CarDetail',verbose_name='图片配对的车型')
    class Meta:
        verbose_name = '车辆图片'
        verbose_name_plural = verbose_name

# 车的类型
# 车的品牌
# 车的颜色
# 车的年龄
# 变速箱
# 里程数
# 排量
# 排放标准
# 座位数
# 燃油类型
# 车牌所在地
# 驱动类型
# 国别
# 亮点

#轮播图
class IndexBanner(models.Model):
    path = models.ImageField(upload_to='static/banner',verbose_name='图片')
    index = models.IntegerField(verbose_name='展示顺序')#展示顺序
    def __str__(self):
        return str(self.path)

    class Meta:
        verbose_name = '首页轮播图'
        verbose_name_plural = verbose_name